<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/3/15 0015
 * Time: 下午 3:09
 */

namespace Admin\Controller;

use Think\Controller;

class LoginController extends Controller
{
    public function checkcode(){
        session(null);
        $Verify = new \Think\Verify(
            array(
                'fontSize' => 30,
                'length'   => 4,
                'useNoise' => True,
            )
        );
        $Verify->entry();
    }
    public function login(){
        if(IS_POST){

            $model = D('Admin');
            if($model->validate($model->_login_validate)->create()){
                if($model->login()){
                    $this->success('登录成功',U('Index/index'));
                    exit;
                }
            }
            $this->error($model->getError());
        }
        $this->display();
    }

    public function logout(){
        $model = D('Admin');
        $model ->logout();
        redirect('login');
    }
}